#/usr/bin/env python
#-*- coding:utf-8 -*-

__author__ = "saintic.com"
__doc__ = "安装系统，帮助信息，setuptools模块，测试系统"
__data__ = "2015-8-1 pm"
__version__ = "2.0"

import os,sys,subprocess,commands

try:
    path=os.path.dirname(os.path.abspath(__file__))
except StandardError, e:
    path=sys.path[0]

def __WriteTmpFile():
    global __pathtmp
    __pathtmp = "/tmp/pythonpathfile"
    with open(__pathtmp,'w') as f:
        f.write('')
    return

def __SOURCE():
    __result=commands.getstatusoutput('source /etc/profile')[0]
    if __result != 0:
        print '错误：source /etc/profile执行故障，PYTHONPATH不存在，脚本退出！'
        ppath = False
        return ppath
    else:
        ppath = True
        return ppath

def __PPATH():
    subprocess.call(['echo ' + 'export PYTHONPATH=' + path + '>> /etc/profile'],shell=True)
    __joinpath=os.path.join(path,'conf')+':'+os.path.join(path,'node')+':'+os.path.join(path,'server')
    subprocess.call(['echo ' + 'export PYTHONPATH=\$PYTHONPATH:' + __joinpath + '>> /etc/profile'],shell=True)
    subprocess.call(["source /etc/profile"],shell=True)

def WritePPATH():
    if os.path.isfile(__pathtmp) == False:
        __PPATH()
        __SOURCE()
        if ppath = True:
            with open(__pathtmp,'w') as f:
                f.write('')
        else:
            print '错误,__SOURCE()函数错误，source执行故障。'
            exit()
    return pythonpath=commands.getstatusoutput('echo $PYTHONPATH')[0]



def Install(Type='Req',System='server'):
    try:
        import GroupInfo
        subprocess.call("yum -y install mailx expect", shell=True)
    except StandardError, e:
        print "安装软件包失败，可能是无法联网或者没有软件源！"
    return 

def help():
    pass
  raw_input('Enter:')
if __name__ == '__main__':
    WritePPATH()
    Install(Type=,System=)
  



